﻿using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Falafel.ViewModel
{
    public static class CollectionExtensions
    {
        /// <summary>
        /// Converts an IEnumerable collection to ObservableCollection. 
        /// Note: Currently, SL does not have a ObservableCollection constructor that takes an 
        /// IEnumerable. 
        /// </summary>
        public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> ie)
        {
            var oc = new ObservableCollection<T>();
            foreach (var item in ie)
            {
                oc.Add(item);
            }            
            return oc;
        }
    }
}
